/*
 * acm1577.c
 *
 *  Created on: 11 Apr 2010
 *      Author: xuxu
 */

#include<stdio.h>
int gcdcount(int a,int b)
{
	int t;
	while(b)
	{
		t=b;
		b=a%b;
		a=t;
	}
	return a;
}
int main()
{
	int gcd,lcm;
	int num1,num2;
	int i,j;
	int con;
	while(scanf("%d%d",&gcd,&lcm)!=EOF)
	{
		con=0;
		for(i=gcd;i<=lcm;i+=gcd)
		{
			if(0!=(lcm*gcd)%i)
				continue;
			j=lcm*gcd/i;
			if(gcd==gcdcount(i>=j?i:j,i>=j?j:i))
				con++;

		}
		printf("%d\n",con);
	}
	return 0;
}
